import 'package:edu_assistant/generated/json/base/json_convert_content.dart';
import 'package:edu_assistant/model/file_item_entity.dart';

FileItemEntity $FileItemEntityFromJson(Map<String, dynamic> json) {
  final FileItemEntity fileItemEntity = FileItemEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    fileItemEntity.id = id;
  }
  final String? url = jsonConvert.convert<String>(json['url']);
  if (url != null) {
    fileItemEntity.url = url;
  }
  final String? thumbImage = jsonConvert.convert<String>(json['thumbImage']);
  if (thumbImage != null) {
    fileItemEntity.thumbImage = thumbImage;
  }
  final String? originFileName = jsonConvert.convert<String>(
      json['originFileName']);
  if (originFileName != null) {
    fileItemEntity.originFileName = originFileName;
  }
  final String? fileType = jsonConvert.convert<String>(json['fileType']);
  if (fileType != null) {
    fileItemEntity.fileType = fileType;
  }
  final int? fileSize = jsonConvert.convert<int>(json['fileSize']);
  if (fileSize != null) {
    fileItemEntity.fileSize = fileSize;
  }
  final int? createTime = jsonConvert.convert<int>(json['createTime']);
  if (createTime != null) {
    fileItemEntity.createTime = createTime;
  }
  final String? timeStr = jsonConvert.convert<String>(json['timeStr']);
  if (timeStr != null) {
    fileItemEntity.timeStr = timeStr;
  }
  return fileItemEntity;
}

Map<String, dynamic> $FileItemEntityToJson(FileItemEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['url'] = entity.url;
  data['thumbImage'] = entity.thumbImage;
  data['originFileName'] = entity.originFileName;
  data['fileType'] = entity.fileType;
  data['fileSize'] = entity.fileSize;
  data['createTime'] = entity.createTime;
  data['timeStr'] = entity.timeStr;
  return data;
}

extension FileItemEntityExtension on FileItemEntity {
  FileItemEntity copyWith({
    int? id,
    String? url,
    String? thumbImage,
    String? originFileName,
    String? fileType,
    int? fileSize,
    int? createTime,
    String? timeStr,
  }) {
    return FileItemEntity()
      ..id = id ?? this.id
      ..url = url ?? this.url
      ..thumbImage = thumbImage ?? this.thumbImage
      ..originFileName = originFileName ?? this.originFileName
      ..fileType = fileType ?? this.fileType
      ..fileSize = fileSize ?? this.fileSize
      ..createTime = createTime ?? this.createTime
      ..timeStr = timeStr ?? this.timeStr;
  }
}